import java.util.Arrays;

public class array {
    //1.数组转字符串
    public static void test1()
    {
        int[] array = new int[]{1,2,3,4,5,6,7,8,9};
        System.out.println(Arrays.toString(array));
    }

    //2.equals用来对比数组
    public static void test2()
    {
        int[] array = new int[]{1,2,3,4,5,6,7,8,9};
        int[] array1 = new int[]{1,2,3,4,5,6,7,8,9};
        System.out.println(Arrays.equals(array, array1));
    }

    //3.fill用来填充数组
    public static void test3()
    {
        int[] array = new int[]{1,2,3,4,5,6,7,8,9};
        Arrays.fill(array,1,4,50);
        System.out.println(Arrays.toString(array));
    }

    //4.sort用来排序数组
    public static void test4()
    {
        int[] array = new int[]{9,8,7,6,5,4,3,2,1};
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
    }

    //5.copyof(要复制的数组, 欲复制的长度多余的使用0补齐)
    //6.copyOfRang(要复制的数组, 要复制的起点， 要复制的终点), 左闭右开
    //7.arraycopy(要复制的数组, 要复制的起点, 要存放的数组, 要存放的起点, 要复制的长度)
    public static void test5()
    {
        int[] array = new int[]{9,8,7,6,5,4,3,2,1};
        int[] copy1 = Arrays.copyOf(array,array.length*2);
        System.out.println(copy1 + ":  " + Arrays.toString(copy1));

        int[] copy2 = Arrays.copyOfRange(array, 0, 3);
        System.out.println(Arrays.toString(copy2));

        int[] copy3 = new int[array.length];
        System.arraycopy(array,0,copy3,0, array.length);
        System.out.println(Arrays.toString(copy3));
    }

    //8.deepTostring打印二维数组
    public static void test6()
    {
        int[][] array1 = {{1,2,3},{4,5,6}};

        int[][] array2 = new int[2][3];

        //二维数组行不能省略
//        int[][] array3 = new int[][3];

        //不规则的二维数组
        int[][] array4 = new int[2][];

        System.out.println(Arrays.deepToString(array1));
    }
    public static void main(String[] args) {
//        test1();
//        test2();
//        test3();
//        test4();
//        test5();
        test6();
    }


}
